package pojo;

/**
 * @author dxw
 * @description 分页类
 * @date 2018-11-01 15:23
 */
public class Page<T> {
    private int total;//总条数
    private int pageSize=1;//每页条数
    private int pageTotal;//总页数
    private int pageCurrent;//当前页数
    private String baseUrl;
    private String additionalUrl="";
    private T content;//该页内容

    /**
     * @param pageSize 每页所包含的条数
     * @param total    总共的条数
     */
    public Page(int pageSize, int total) {
        this.pageSize = pageSize;
        if(pageSize>1){
            this.total = total;
        }
        init();
    }

    private Page() {
    }

    private void init(){
        if(total%pageSize==0){
            pageTotal = total/pageSize;
        }else {
            pageTotal = total/pageSize+1;
        }
        pageCurrent=1;
        baseUrl="";
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(int pageTotal) {
        this.pageTotal = pageTotal;
    }

    public int getPageCurrent() {
        return pageCurrent;
    }

    public void setPageCurrent(int pageCurrent) {
        this.pageCurrent = pageCurrent;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }

    public int getTotal() {
        return total;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getAdditionalUrl() {
        return additionalUrl;
    }

    public void setAdditionalUrl(String additionalUrl) {
        this.additionalUrl = additionalUrl;
    }

    @Override
    public String toString() {
        return "Page{" + "total=" + total + ", pageSize=" + pageSize + ", pageTotal=" + pageTotal + ", pageCurrent=" + pageCurrent + ", content=" + content + '}';
    }

    public void setTotal(int total) {
        this.total = total;
    }
}
